class CreateContacts < ActiveRecord::Migration[5.1]
  def change
    create_table :contacts do |t|
      t.string :name, limit: 20, null: false, index: true, comment: '姓名'
      t.integer :gender, default: 0, comment: '性别 1-先生 2-女士'
      t.string :dept_name, limit: 20, comment: '部门'
      t.integer :important_level, default: 0, comment: '重要性 1-重要 2-普通'  
      t.string :tel_no, limit: 11, comment: '手机号码'
      t.string :phone_no, limit: 20, comment: '电话号码'
      t.string :email, limit: 50, comment: '邮箱'
      t.string :note, limit: 200, comment: '备注'
      t.integer :is_delete, default: 0, null: false, comment: '是否删除 1-删除 0-未删除'

      t.timestamps
    end
    add_reference :contacts, :companies, foreign_key: true
  end
end
